package com.shopping.serviceImpl;

import com.shopping.dao.CommentDao;
import com.shopping.pojo.Comment;
import com.shopping.pojo.vo.CommentInfo;
import com.shopping.pojo.vo.ProductCommentInfo;
import com.shopping.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentDao commentDao;


    @Override
    public List<CommentInfo> selectCommentByQuery(String userName, String productName, int start, int limit) {
        return commentDao.selectCommentByQuery(userName, productName, start, limit);
    }

    @Override
    public int getCommentNum(String userName, String productName) {
        return commentDao.getCommentNum(userName,productName);
    }

    @Override
    public List<CommentInfo> selectCommentByProductId(Integer productId) {
        return commentDao.selectCommentByProductId(productId);
    }

    @Override
    public boolean insertComment(Comment comment) {
        return commentDao.insertComment(comment)>0;
    }

    @Override
    public boolean deleteComment(Integer commentId) {
        return commentDao.deleteComment(commentId)>0;
    }

    @Override
    public List<ProductCommentInfo> selectCommentByUserId(Integer userId) {
        return commentDao.selectCommentByUserId(userId);
    }
}
